package org.wekit.engine.pvm.delegate;

import java.util.List;

import org.wekit.engine.pvm.PvmActivity;
import org.wekit.engine.pvm.PvmProcessDefinition;
import org.wekit.engine.pvm.PvmProcessInstance;
import org.wekit.engine.pvm.PvmTransition;

/**
 * 动作节点执行接口
 * @author HuangWeili
 *
 */
public interface ActivityExecution extends DelegateExecution {

	/**
	 * 获取执行所在的流程节点
	 * @return
	 */
	PvmActivity getActivity();
	
	/**
	 * 获取路由
	 * @param pvmTransition
	 */
	void take(PvmTransition pvmTransition);
	
	/**
	 * 创建流转对象
	 * @return
	 */
	ActivityExecution createExecution();
	
	/**
	 * 创建子流程
	 * @param processDefinition
	 * @return
	 */
	PvmProcessInstance createSubProcessInstance(PvmProcessDefinition processDefinition);
	
	/**
	 * 获取父执行对象
	 * @return
	 */
	ActivityExecution getParent();
	
	/**
	 * 获取流转对象
	 * @return
	 */
	List<? extends ActivityExecution> getExecutions();
	
	/**
	 * 流转结束动作
	 */
	void end();
	
	/**
	 * 设置激活状态
	 * @param isActive
	 */
	void setActive(boolean isActive);
	
	/**
	 * 判断是否是激活状态
	 * @return
	 */
	boolean isActive();
	
	/**
	 * 判断流程是否结束
	 * @return
	 */
	boolean isEnded();
	
	/**
	 * 设置为并发状态
	 * @param isConcurrent
	 */
	void setConcurrent(boolean isConcurrent);
	
	/**
	 * 判断是否是并发状态
	 * @return
	 */
	boolean isConcourrent();
	
	/**
	 * 判断是否是流程实例
	 * @return
	 */
	boolean isProcessInstance();
	
	/**
	 * 反激活对象
	 */
	void inactivate();
	
	/**
	 * 是否是组合流程
	 * @return
	 */
	boolean isScope();
	
	/**
	 * 设置为组合流程
	 * @param isScope
	 */
	void setScope(boolean isScope);
	
	/**
	 * 查找未激活执行
	 * @param activity
	 * @return
	 */
	List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity);
	
	/**
	 * 获取所有的执行状态
	 * @param outgoingTransitions
	 * @param joinedExecutions
	 */
	void takeAll(List<PvmTransition> outgoingTransitions,List<ActivityExecution> joinedExecutions);
	
	/**
	 * 执行节点动作
	 * @param activity
	 */
	void executeActivity(PvmActivity activity);
}
